package com.gm.baseplatform.base.cfg;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class ConfigDao extends HibernateDaoSupport {

	public void saveConfig(Configuration cfg) {
		getHibernateTemplate().save(cfg);
	}
	
	public void updateConfig(Configuration cfg) {
		getHibernateTemplate().update(cfg);
	}
	
	public Configuration findConfigByName(String name) {
		List<?> cfgList = getHibernateTemplate().find("from Configuration where name = '"+ name +"'");
		if (cfgList != null && !cfgList.isEmpty()) {
			return (Configuration)cfgList.get(0);
		}
		return null;
	}
	
	public List<?> loadConfigs() {
		List<?> cfgList = getHibernateTemplate().find("from Configuration");
		return cfgList;
	}
}
